package com.example.demo1.model;

import lombok.Data;

import java.util.Date;
import java.util.List;
@Data
public class Organization {
    private Integer id;
    private String name;
    private Integer parentId;
    private String path;
    private Integer level;
    private Date createTime;
    private Date updateTime;

    // 用于返回树形结构
    private List<Organization> children;

    // 验证方法
    public void validate() {
        if (name == null || name.trim().isEmpty()) {
            throw new IllegalArgumentException("组织名称不能为空");
        }
        if (path != null && !path.matches("^\\d+(/\\d+)*/$")) {
            throw new IllegalArgumentException("路径格式不正确");
        }
    }
}
